package com.alpha.framework.inter.impl;

import com.alpha.framework.R;
import com.alpha.framework.activity.BaseActivity;
import com.alpha.framework.bean.BaseInfo;
import com.alpha.framework.inter.IAccessServer;
import com.alpha.framework.utils.StringUtils;
import com.alpha.framework.utils.UIUtils;


public abstract class DefaultAccessServerImpl<Data> implements IAccessServer<Data> {

	@Override
	public void onPreExecute(String loadingMessage) {
		
	}
	
	@Override
	public void onPostExecute() {
		
	}

	
	@Override
	public void success(Data data) {
		showMessage(data);
	}

	@Override
	public void failure(Data data) {
		showMessage(data);
	}

	@Override
	public void networkErr() {
		//提示无法访问网络
		UIUtils.showToastSafe(UIUtils.getString(R.string.network_err));
	}

	/**
	 * 显示服务器返回message
	 * @param data
	 */
	private void showMessage(Data data){
		if(data instanceof BaseInfo){
			UIUtils.showToastSafe(((BaseInfo)data).message);
		}
	}

}
